package com.baidu.controller;
import com.baidu.entity.Borr;
import com.baidu.entity.Sked;
import com.baidu.service.OverdueService;
import com.baidu.utils.ResultResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
 * @Description: 还款控制层
 * @Author: 王雨超
 * @Date: 2021/12/11 13:37
 */
@Slf4j
@RestController
@CrossOrigin
@RequestMapping("/Over")
@SuppressWarnings({"all"})
public class OverdueController {
    @Autowired
    private OverdueService overdueService;
    /**
    *@Description: 通过用户id查询还款计划
    *@Author: 王雨超
    *@Date: 2021/12/16
    *@Param:  用户id
    *@return: List
    */
    @PostMapping("/findBorr")
    public List<Sked> findBorr(@RequestParam("userid") int userid){
        return overdueService.findBorr(userid);
    }
    /**
    *@Description: 提前全部还款方法 计算出应还的金额
    *@Author: 王雨超
    *@Date: 2021/12/16
    *@Param: 用户id 产品id
    *@return: Double
    */
    @PostMapping("/findMoney")
    public Double findMoney(@RequestParam("userid") int userid){
        return overdueService.findMoney(userid);
    }
    /**
    *@Description: 提前全部还款方法
    *@Author: 王雨超
    *@Date: 2021/12/16
    *@Param: userid moeny
    *@return: 
    */
    @PostMapping("/prepayment")
    public ResultResponse prepayment(@RequestParam("userid") int userid, double money){
        return overdueService.prepayment(userid,money);
    }
    /**
    *@Description: 查询按期还款金额
    *@Author: 王雨超
    *@Date: 2021/12/20
    *@Param: 用户id 期数id
    *@return: 金额
    */
    @PostMapping("/scheduleMoney")
    public Double scheduleMoney(@RequestParam("userid") int userid,@RequestParam("wvs") int wvs) {
        return overdueService.scheduleMoney(userid,wvs);
    }
    /**
    *@Description: 按期还款方法
    *@Author: 王雨超
    *@Date: 2021/12/20
    *@Param: 用户id 期数id 还款金额
    *@return: ResultResponse
    */
    @PostMapping("/schedule")
    public ResultResponse schedule(@RequestBody Map<String,String> map){
        return overdueService.schedule(map);
    }
    /**
    *@Description: 提前还款查看还款清单
    *@Author: 王雨超
    *@Date: 2021/12/23
    *@Param: userid
    *@return: List<borr>
    */
    @PostMapping("/findBorrList")
    public List<Borr> findBorrList(@RequestParam("userid") int userid){
        return overdueService.findBorrList(userid);
    }
    /**
    *@Description: 查询提前还款应还金额
    *@Author: 王雨超
    *@Date: 2021/12/23
    *@Param: 期数  借款记录id
    *@return: 金额 nums
    */
    @PostMapping("/findNums")
    public Double findNums(@RequestParam("bid") int bid){
        return overdueService.findNums(bid);
    }
    /**
    *@Description: 提前还款方法
    *@Author: 王雨超
    *@Date: 2021/12/23
    *@Param: 借款主键id  借款金额
    *@return: ResultResponse
    */
    @PostMapping("/advance")
    public ResultResponse advance(@RequestParam("bid") int bid,@RequestParam("money") Double money,@RequestParam("userid") int userid){
        return overdueService.advance(bid,money,userid);
    }
    /**
    *@Description: 最低还款：查询还款计划
    *@Author: 王雨超
    *@Date: 2021/12/24
    *@Param: userid 用户id
    *@return: ResultResponse
    */
    @PostMapping("/minimum")
    public ResultResponse minimum(@RequestParam("userid") int userid){
        return overdueService.minimum(userid);
    }
    /**
    *@Description: 最低还款：计算最低还款金额
    *@Author: 王雨超
    *@Date: 2021/12/24
    *@Param: 用户id  userid 期数  wvs
    *@return: Double 最低还款额
    */
    @PostMapping("/minmoney")
    public Double minmoney(@RequestParam("userid") int userid,@RequestParam("wvs") int wvs){
        return overdueService.minmoney(userid,wvs);
    }
    /**
    *@Description: 最低还款
    *@Author: 王雨超
    *@Date: 2021/12/24
    *@Param: 用户id  userid 期数  wvs 最低还款额 minmoney
    *@return: ResultResponse
    */
    @PostMapping("/minpayment")
    public ResultResponse minpayment(@RequestParam("userid") int userid,@RequestParam("wvs") int wvs,@RequestParam("minmoney") double minmoney){
        return overdueService.minpayment(userid,wvs,minmoney);
    }
}
